-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable IO and UpdateTest types #15104
Conversation
@@ -1,22 +1,24 @@ | |||
# typed: false | |||
# typed: true | |||
# frozen_string_literal: true | |||
|
|||
class IO | |||
def readline_nonblock(sep = $INPUT_RECORD_SEPARATOR) | |||
line = +"" | |||
buffer = +"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be outside the rescue
d block, so that line
is provably a String
when line.empty?
is invoked below.
raise e if line.empty? | ||
line.freeze | ||
rescue IO::WaitReadable, EOFError | ||
raise if line.empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IO::WaitReadable
is not technically an Exception, so it can't be passed to raise
, but we can avoid the issue using an empty re-raise instead (e
is not needed otherwise)
bcfcb64
to
fa0caaa
Compare
Very interesting! |
end_commit = "HEAD" | ||
cd HOMEBREW_REPOSITORY do | ||
start_commit = if (commit = args.commit) | ||
start_commit = if (commit = T.let(args.commit, T.nilable(String))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really necessary? I tested it locally and it didn't seem to care.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, are some of these changes only needed for typed: strict
@dduugg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, this is a vestige of attempting to type the Utils.popen*
methods. Would you like me to remove it in the next typing PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dduugg No, all good!
end_commit = "HEAD" | ||
cd HOMEBREW_REPOSITORY do | ||
start_commit = if (commit = args.commit) | ||
start_commit = if (commit = T.let(args.commit, T.nilable(String))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, are some of these changes only needed for typed: strict
@dduugg?
Thanks again @dduugg! Happy to chat more post-merge. |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Enables types in Library/Homebrew/extend/io.rb and Library/Homebrew/dev-cmd/update-test.rb
Note that this is a bit clumsy in one case, where we mark an lvar as
untyped
. This is becauseUtils.popen_read
resists a straightforwardsig
(The return type is the return type of the block given to it, or aString
otherwise. Sorbet allows multiple sigs in the Ruby core and std libraries in order to express this, but doesn't allow it otherwise.)